using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Web.UI;
using System.Web.UI.WebControls;

using DotNetNuke;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using Common;

using System.Security.Cryptography;
using System.Text;
using System.IO;

namespace AdminTools
{
    partial class ViewAdminTools : PortalModuleBase, IActionable
    {

        #region Private Members
        TabController tabController = new TabController();
        TabInfo tabInfo = new TabInfo();
        ModuleController moduleController = new ModuleController();
        ModuleInfo moduleInfo = new ModuleInfo();
        int tabId = 0, moduleId = 0;
        private int loginUserType
        {
            get
            {
                if (Session["loginUserType"] == null) return 0;
                return (int)Session["loginUserType"];
            }
        }
        #endregion

        #region Public Methods

        public bool DisplayAudit()
        {
            bool retValue = false;

            if ((string)Settings["auditinfo"] == "Y")
            {
                retValue = true;
            }

            return retValue;
        }

        #endregion

        #region private function
       
        #endregion

               
        #region Optional Interfaces

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Registers the module actions required for interfacing with the portal framework
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public ModuleActionCollection ModuleActions
        {
            get
            {
                ModuleActionCollection Actions = new ModuleActionCollection();
                Actions.Add(this.GetNextActionID(), Localization.GetString(ModuleActionType.AddContent, this.LocalResourceFile), ModuleActionType.AddContent, "", "", this.EditUrl(), false, SecurityAccessLevel.Edit, true, false);
                return Actions;
            }
        }

        #endregion

        #region Event Handlers

        protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    //The control is visible if there is any  button is visible;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        protected void btnNews_Click(object sender, EventArgs e)
        {
            string tabName  = this.PortalSettings.ActiveTab.TabName.Trim();
            tabInfo = tabController.GetTabByName("newsmana",consts.constSystemPortalId);
            moduleInfo = moduleController.GetModuleByDefinition(consts.constSystemPortalId , "newsmana");
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(tabInfo.TabID));
        }
        protected void btnAdvert_Click(object sender, EventArgs e)
        {
            string tabName = this.PortalSettings.ActiveTab.TabName.Trim();
            tabInfo = tabController.GetTabByName("advert", consts.constSystemPortalId);
            moduleInfo = moduleController.GetModuleByDefinition(consts.constSystemPortalId, "advert");
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(tabInfo.TabID));
            
            //tabInfo = tabController.GetTabByName("advert", PortalSettings.PortalId);
            //Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(tabInfo.TabID));

            //string tabName = this.PortalSettings.ActiveTab.TabName.Trim();
            //tabInfo = tabController.GetTabByName(tabName, PortalSettings.PortalId);
            //moduleInfo = moduleController.GetModuleByDefinition(0, "advert");
            //Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(tabInfo.TabID));
        }
        #endregion
    }
}

